package com.ems.mapper;

import com.ems.entity.DeviceEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ems.vo.DeviceVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 * 设备 Mapper 接口
 * </p>
 * @author WuZH
 * @since 2024-05-08
 */
@Mapper
public interface DeviceMapper extends BaseMapper<DeviceEntity> {

    @Update (value = "<script>UPDATE device_info" +
                        "<trim prefix=\"set\" suffixOverrides=\",\">" +
                            "<if test=\"deviceVo.changeTime!=null\">changeTime=#{deviceVo.changeTime}</if>" +
                            "<if test=\"deviceVo.connectStatus!=null\">,connectStatus=#{deviceVo.connectStatus}</if>" +
                            "<if test=\"deviceVo.chargeDisPower!=null\">,chargeDisPower=#{deviceVo.chargeDisPower}</if>" +
                        "</trim>" +
                        "WHERE deviceAddress=#{deviceVo.deviceAddress}" +
                        "</script>")
    void updateSingle (@Param ("deviceVo") DeviceVo deviceVo);

}
